package com.Practice.estore.service;
import com.Practice.estore.model.Product;
import java.util.Comparator;
@SuppressWarnings("unused")
public class ProductSorters {
    // 按商品价格从低到高排序
    public static final Comparator<Product> BY_PRICE_ASC = Comparator.comparingDouble(Product::getPrice);

    // 按商品价格从高到低排序（基于升序比较器反转）
    @SuppressWarnings("unused")
    public static final Comparator<Product> BY_PRICE_DESC = BY_PRICE_ASC.reversed();

    // 按商品库存从多到少排序（基于库存升序比较器反转）
    @SuppressWarnings("unused")
    public static final Comparator<Product> BY_STOCK_DESC = Comparator.comparingInt(Product::getStock).reversed();

    // 按商品名称排序
    public static final Comparator<Product> BY_NAME_ASC = Comparator.comparing(Product::getName);
    @SuppressWarnings("unused")
    public static final Comparator<Product> BY_NAME_DESC = BY_NAME_ASC.reversed();
}